package com.chenchao.net;

import java.io.IOException;
import java.net.*;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/25 21:24
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.net.Test10B.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 广播方式端
 */
public class Test10B {
    public static void main(String[] args) throws IOException {
        /*建码头*/
        DatagramSocket socket = new DatagramSocket();
        /*建集装箱*/
        String str ="这里是CCTV1";
        InetAddress address = InetAddress.getByName("255.255.255.255");
        DatagramPacket datagramPacket =
                new DatagramPacket(str.getBytes(),str.getBytes().length,address,10000);
        /*发船*/
        socket.send(datagramPacket);
        /*关码头*/
        socket.close();

    }
}
